﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClrExporter
{
    class DataExtractor
    {
        public static T To<T>(SqlDataReader dr, string fieldName)
        {
            var ordinal = dr.GetOrdinal(fieldName);
            if (dr.IsDBNull(ordinal))
            {
                return default(T);
            }
            else
            {
                return dr.GetFieldValue<T>(ordinal);
            }
        }
    }
}
